package com.mvc.controller;


import java.util.List;

import com.common.core.BaseController;
import com.jfinal.kit.JsonKit;
import com.mvc.request.ReqPage;
import com.mvc.request.ReqVenueDelete;
import com.mvc.request.ReqVenueDetail;
import com.mvc.request.ReqVenueUserPage;
import com.mvc.request.ReqVenueAdd;
import com.mvc.request.ReqVenueUpdate;
import com.mvc.request.ReturnData;
import com.mvc.response.RspPage;
import com.mvc.response.RspVenue;
import com.mvc.response.RspVenueDetail;
import com.mvc.service.VenueService;
import com.mvc.service.impl.VenueServiceImpl;

/**
 * 场馆
 */
public class VenueController extends BaseController {

	VenueService venueService = new VenueServiceImpl();

	// 1 新建场馆
	public void add() {

		ReqVenueAdd req_Venue = this.getRequestObject(ReqVenueAdd.class);
		ReturnData<Boolean> data = this.venueService.create(req_Venue);
		renderJson(JsonKit.toJson(data));
	}

	// 2 更新纪念馆资料
	public void update() {

		ReqVenueUpdate req_Venue = this
				.getRequestObject(ReqVenueUpdate.class);
		ReturnData<Boolean> data = this.venueService.update(req_Venue);
		renderJson(JsonKit.toJson(data));
	}

	// 3 根据场馆ID场馆详情
	public void getVenueDetail() {

		ReqVenueDetail req = this.getRequestObject(ReqVenueDetail.class);
		ReturnData<RspVenueDetail> data = this.venueService.getVenueDetail(req);
		renderJson(JsonKit.toJson(data));

	}

	// 4 根据场馆ID删除纪念馆【删除所有相关信息]1.留言记录 2.逝者信息 3.祭拜记录 4.生平事迹 5.相关图片】
	public void delete() {
		ReqVenueDelete req = this.getRequestObject(ReqVenueDelete.class);
		ReturnData<Boolean> data = this.venueService.delete(req);
		renderJson(JsonKit.toJson(data));
	}

	// 5 根据用户ID获取用户所有纪念馆
	public void queryUserAll() {

		ReqVenueUserPage req = this.getRequestObject(ReqVenueUserPage.class);
		ReturnData<List<RspVenue>> data = this.venueService
				.queryUserPage(req);
		renderJson(JsonKit.toJson(data));
	}

	// 获取场馆排名列表【条件依据场馆怀念币数量】
	public void queryPageRanking() {
		ReqPage req = this.getRequestObject(ReqPage.class);
		ReturnData<RspPage<RspVenue>> data = this.venueService
				.queryRankingPage(req);
		renderJson(JsonKit.toJson(data));
	}

	// 推荐场馆列表
	public void queryNominate() {
		ReqPage req = this.getRequestObject(ReqPage.class);
		ReturnData<RspPage<RspVenue>> data = this.venueService
				.queryWorshipPage(req);
		renderJson(JsonKit.toJson(data));
	}

	// 最新创建场馆列表【创建时间排序】
	public void queryNewList() {
		ReqPage req = this.getRequestObject(ReqPage.class);
		ReturnData<RspPage<RspVenue>> data = this.venueService
				.queryNewPage(req);
		renderJson(JsonKit.toJson(data));
	}

}
